import type { MultipleConditionSearchSchema } from '@/components/multiple-condition-search/types'

export default function useConfig() {
  const searchSchema = computed<MultipleConditionSearchSchema>(() => {
    return {
      placeholder: '默认按照节点 IP 搜索',
      widgets: [
        {
          type: 'input',
          label: '节点 IP',
          field: 'ip_keyword',
          maxLength: 30,
        },
        {
          type: 'input',
          label: '节点名称',
          field: 'name_keyword',
        },
      ],
    }
  })
  const tableColumns = buildColumns([
    {
      title: '节点名称',
      dataIndex: 'name',
    },
    {
      title: '节点 IP',
      dataIndex: 'ip',
    },
    {
      title: '节点状态',
      dataIndex: 'run_status',
      slotName: 'runStatus',
    },
    {
      title: '节点版本',
      dataIndex: 'version',
      slotName: 'version',
    },
    {
      title: '创建时间 ',
      dataIndex: 'created_at',
      format: 'date-time',
      sortable: sortableSettings,
    },
    {
      title: '操作',
      fixed: 'right',
      slotName: 'actions',
      width: 80,
      cellClass: 'actions-cell',
    },
  ])

  return {
    tableColumns,
    searchSchema,
  }
}
